package com.cq.hd.admin.controller;

import com.cq.hd.admin.annotation.RequiresPermissionsDesc;
import com.cq.hd.common.enums.biz.FinancialAccountTypeEnum;
import com.cq.hd.common.enums.biz.WithdrawalTypeEnum;
import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.member.api.TbWithdrawalBillApi;
import com.cq.hd.member.api.dto.AdminWithdrawalApplyAuditDto;
import com.cq.hd.member.api.dto.AdminWithdrawalApplyPageDto;
import com.cq.hd.member.api.vo.AdminWithdrawalAmtVo;
import com.cq.hd.member.api.vo.AdminWithdrawalApplyPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "商户补贴提现审核相关接口(自建商户)")
@Slf4j
@RestController
@RequestMapping("/merchantSubsidyWithdrawalBill")
public class TbMerchantSubsidyWithdrawalBillController extends BaseController{

    @Autowired
    private TbWithdrawalBillApi withdrawalBillApi;

    @ApiOperation(value = "获取累计申请金额，累计已提现金额")
    @RequiresPermissions("finance:merchantSubsidyWithdrawalBill:getWithdrawalAmt")
    @RequiresPermissionsDesc(menu = {"财务管理", "商户补贴提现审核"}, button = "累计查询")
    @GetMapping("/getWithdrawalAmt")
    public Result<AdminWithdrawalAmtVo> getWithdrawalAmt(AdminWithdrawalApplyPageDto adminWithdrawalApplyPageDto) {
        adminWithdrawalApplyPageDto.setWithdrawalType(WithdrawalTypeEnum.MERCHANT_SUBSIDY.getValue());
        adminWithdrawalApplyPageDto.setMerchantFinancialAccountType(FinancialAccountTypeEnum.SELF.getValue());
        return withdrawalBillApi.getWithdrawalAmt(adminWithdrawalApplyPageDto);
    }

    @ApiOperation(value = "商户补贴提现审核列表")
    @RequiresPermissions("finance:merchantSubsidyWithdrawalBill:list")
    @RequiresPermissionsDesc(menu = {"财务管理", "商户补贴提现审核"}, button = "查询")
    @GetMapping("/page")
    public Result<Page<AdminWithdrawalApplyPageVo>> page(AdminWithdrawalApplyPageDto adminWithdrawalApplyPageDto) {
        adminWithdrawalApplyPageDto.setWithdrawalType(WithdrawalTypeEnum.MERCHANT_SUBSIDY.getValue());
        adminWithdrawalApplyPageDto.setMerchantFinancialAccountType(FinancialAccountTypeEnum.SELF.getValue());
        return withdrawalBillApi.pageAdminWithdrawalBill(adminWithdrawalApplyPageDto);
    }

    @ApiOperation(value = "商户补贴提现审核")
    @RequiresPermissions("finance:merchantSubsidyWithdrawalBill:audit")
    @RequiresPermissionsDesc(menu = {"财务管理", "商户补贴提现审核"}, button = "审核")
    @PostMapping("/audit")
    public Result<Boolean> audit(@RequestBody AdminWithdrawalApplyAuditDto adminWithdrawalApplyAuditDto) {
        return withdrawalBillApi.audit(adminWithdrawalApplyAuditDto);
    }


}
